package gorillamux

import (
	"fmt"
	"github.com/gorilla/mux"
	"io"
	"net/http"
)

func Index(w http.ResponseWriter, r *http.Request) {
	// fmt.Fprintln(w, "Hello !")
	// Response(w, "Login success.", "SUCCESS", 200)
	io.WriteString(w, "Logidfsjkj")
}

func UserInfo2(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	uId := vars["uId"]
	fmt.Fprintf(w, "userInfo %q", uId)
}

/*type response struct {
	Status      int    `json:"status"`
	Description string `json:"description"`
	Code        string `json:"code"`
}*/

/*func Response(w http.ResponseWriter, description string, code string, status int) {
	// out := &response{status, description, code}
	// b, err := json.Marshal(out)
	// if err != nil {
	// 	return
	// }
	// w.WriteHeader(status)
	// w.Write("description")
}*/
func UserLogin(w http.ResponseWriter, r *http.Request) {

	ret := `{"code": 20000,"data": { "token": "admin"}}`
	//设置响应头
	// w.Header().Set("Content-Type", "application/json; charset=utf-8")

	io.WriteString(w, ret)

}

func UserInfo(w http.ResponseWriter, r *http.Request) {

	ret := "{\"code\":20000,\"data\":{\"role\":[\"admin\"],\"name\":\"admin\",\"avatar\":\"\"}}"
	//设置响应头
	//	w.Header().Set("Content-Type", "application/json; charset=utf-8")

	io.WriteString(w, ret)

}
